// * 用户信息验证
const joi = require('joi');

const username = joi.string().alphanum().min(1).max(10).required();

const password = joi
  .string()
  .pattern(/^[\S]{2,12}$/)
  .required();

const id = joi.number().integer().min(1).required();

const nickname = joi.string().required();

const email = joi.string().email().required();

const avatar = joi.string().required();

exports.reg_login_schema = {
  body: {
    username,
    password,
  },
};

exports.update_userInfo_schema = {
  body: {
    id,
    nickname,
    email,
  },
};

exports.update_password_schema = {
  body: {
    oldPwd: password,
    newPwd: joi.not(joi.ref('oldPwd')).concat(password),
  },
};

exports.update_avatar_schema = {
  body: {
    avatar,
  },
};

exports.update_nickname_schema = {
  body: {
    nickname,
  },
};
